package com.kernel;

import java.util.Observable;

/****************************************
 * @name House
 * @description 房子类，被观察的对象
 * @author 黄彬恒
 * @since 2018/7/31
 ***************************************/
public class House extends Observable {
    private float price;

    public House(float price) {
        this.price = price;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        /*每次修改之后都应该引起观察者注意*/
        super.setChanged(); // 设置变化点
        super.notifyObservers(price); // 价格有变化
        this.price = price;
    }

    @Override
    public String toString() {
        return "房子的价格为：" + this.price;
    }
}
